interface IUser {
    id: number,
    name: string,
    address?: string,
    play: () => void
}

let myuser: IUser = {
    id: 1,
    name: "xiaowang",
    play: () => {

    }
}

let myuser2: IUser = {
    id: 1,
    name: "xiaowang",
    address: "武侯区",
    play: function () { }
}

interface IProduct {
    id: number,
    name: string;
    title: string;
    price: number;
    state: boolean;
    type?: IType
}
interface IType {
    id: number,
    name: string
}
const product: IProduct = {
    id: 1,
    name: "小米耳机",
    title: "降噪耳机",
    price: 120,
    state: true,
    type: {
        id: 1,
        name: "一级分类"
    }
}

//类型别名
type uniType = IType | undefined | null

function showMsg(product: IProduct): uniType {
    return product.type
}
function findMsg(msg: uniType) {

}
findMsg(null)

interface IMenu {
    id: number;
    title: string;
    path: string;
}
interface IMenu2 {
    id: number;
    title: string;
    path: string;
    children:string
}

// 类型别名----联合类型:多种数据约束组合在一起
type aliasMenu = IMenu | IMenu2


let menus:Array<aliasMenu> = [
    { id: 1, title: "首页", path: "/home" },
    {
        id: 2, title: "商品", path: "/home", children: ""
    },
]

// type user3 = {
//     id:number,
//     name:string
// }



export {}
